package com.gzc.just.play.last.war.sceneserver.goods;

/**
 * 物品类型枚举 - 定义游戏中所有的物品类型
 *
 * @author AI编程助手
 * @version 1.0
 * @since 2025-11-22
 */
public enum GoodsType {
    // 装备
    WEAPON("武器", 1),
    ARMOR("防具", 2),
    HELMET("头盔", 3),
    BOOTS("靴子", 4),
    AMULET("护符", 5),
    
    // 消耗品
    HEALTH_POTION("生命药水", 10),
    MANA_POTION("魔力药水", 11),
    REVIVE_SCROLL("复活卷轴", 12),
    TELEPORT_SCROLL("传送卷轴", 13),
    
    // 材料
    ORE("矿石", 20),
    HERB("药草", 21),
    LEATHER("皮革", 22),
    WOOD("木材", 23),
    FABRIC("布料", 24),
    
    // 任务物品
    QUEST_ITEM("任务物品", 30),
    
    // 宝物
    TREASURE("宝物", 40),
    ARTIFACT("工艺品", 41),
    
    // 其他
    UNKNOWN("未知物品", 0);
    
    private final String displayName;
    private final int typeId;
    
    GoodsType(String displayName, int typeId) {
        this.displayName = displayName;
        this.typeId = typeId;
    }
    
    public String getDisplayName() {
        return displayName;
    }
    
    public int getTypeId() {
        return typeId;
    }
    
    /**
     * 是否为装备类
     */
    public boolean isEquipment() {
        return this.ordinal() >= WEAPON.ordinal() && this.ordinal() <= AMULET.ordinal();
    }
    
    /**
     * 是否为消耗品
     */
    public boolean isConsumable() {
        return this.ordinal() >= HEALTH_POTION.ordinal() && this.ordinal() <= TELEPORT_SCROLL.ordinal();
    }
    
    /**
     * 是否为材料
     */
    public boolean isMaterial() {
        return this.ordinal() >= ORE.ordinal() && this.ordinal() <= FABRIC.ordinal();
    }
    
    /**
     * 根据ID获取物品类型
     */
    public static GoodsType getByTypeId(int typeId) {
        for (GoodsType type : GoodsType.values()) {
            if (type.typeId == typeId) {
                return type;
            }
        }
        return UNKNOWN;
    }
}
